package org.oslims.client.view.impl;

import org.oslims.client.uicomponents.editbox.EditSampleTypeBox;
import org.oslims.client.view.SampleTypeEditorView;
import org.oslims.domain.SampleType;

import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.event.dom.client.HasClickHandlers;
import com.google.gwt.user.cellview.client.CellTable;
import com.google.gwt.user.cellview.client.SimplePager;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DockLayoutPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.ScrollPanel;
import com.google.gwt.user.client.ui.VerticalPanel;

public class SampleTypeEditorViewImpl extends BaseViewImpl implements SampleTypeEditorView {

	final Button addSampleTypeButton = new Button("Add sampleType");

	Integer defaultPageSize = 15;
	final CellTable<SampleType> sampleTypeTable = new CellTable<SampleType>(defaultPageSize);

	final SimplePager<SampleType> pager = new SimplePager<SampleType>(sampleTypeTable);

	EditSampleTypeBox editsampleTypeBox = new EditSampleTypeBox();

	public SampleTypeEditorViewImpl() {
		DockLayoutPanel content = new DockLayoutPanel(Unit.PCT);
		content.setStyleName("mainContent");

		VerticalPanel headerPanel = new VerticalPanel();

		Label header = new Label("Sample Type Management");
		header.setStyleName("viewHeader");

		headerPanel.add(header);
		content.addNorth(headerPanel, 5);

		VerticalPanel footerPanel = new VerticalPanel();
		footerPanel.add(pager);
		footerPanel.add(addSampleTypeButton);
		content.addSouth(footerPanel, 10);

		ScrollPanel tablePanel = new ScrollPanel();
		tablePanel.add(sampleTypeTable);

		content.add(tablePanel);

		initWidget(content);
	}

	@Override
	public HasClickHandlers getAddSampleTypeButton() {
		return addSampleTypeButton;
	}

	@Override
	public CellTable<SampleType> getTable() {
		return sampleTypeTable;
	}

	@Override
	public EditSampleTypeBox getEditSampleTypeBox() {
		return editsampleTypeBox;
	}

	@Override
	public SimplePager<SampleType> getPager() {
		return pager;
	}

	@Override
	public Integer getDefaultPageSize() {
		return defaultPageSize;
	}

}
